# import time


#
#
# def my_fun():
#     begin = time.time()
#     time.sleep(2)          # 这里让结果看起来更直观点，睡眠了2秒
#     print("这里一个函数")
#     end = time.time()
#     print(end - begin)
#
#
# my_fun()
# def my_fun():
#     print("这是一个函数")
#
#
# def my_time(func):
#     begin = time.time()
#     time.sleep(2)
#     func()
#     end = time.time()
#     print(end - begin)
#
#
# my_time(my_fun)
import time


def print_cost(func):
    def wrapper():
        begin = time.time()
        time.sleep(2)
        func()
        end = time.time()
        print(end - begin)

    return wrapper


@print_cost
def my_fun():
    print("这里一个函数")

my_fun()
